home *** CD-ROM | disk | FTP | other *** search
- Path: doc.ic.ac.uk!not-for-mail
- From: rwmj@doc.ic.ac.uk (Richard Jones)
- Newsgroups: comp.lang.c
- Subject: Override a cpp macro?
- Date: 10 Jan 1996 18:05:47 -0000
- Organization: Dept. of Computing, Imperial College, University of London, UK.
- Distribution: world
- Message-ID: <4d0v5r$6fs@oak78.doc.ic.ac.uk>
- NNTP-Posting-Host: oak78.doc.ic.ac.uk
-
- I'm trying to redefine a cpp macro, but using the old definition. I've got
- a macro defined:
-
- #define m1(a,b) /* some hidden definition of m1 */
-
- and in another file, I want to redefine m1 in terms of the old (unknown)
- definition. Two obvious ways would be:
-
- #define old_m1(a,b) m1(a,b)
- #undef m1
- #define m1(a,b) (old_m1(a,b)+1)
-
- or:
-
- #define new_m1(a,b) (m1(a,b)+1)
- #undef m1
- #define m1(a,b) new_m1(a,b)
-
- But neither works as expected. I've tried variations using the macro:
-
- #define expand(a) a
-
- which according to the Gnu info page for (Gnu) cpp should expand the
- argument first. However, no known combination works.
-
- What's the way to do this? Surely this is an obvious thing to want to do,
- so there must be some simple point I'm missing?
-
- Rich.
- --
- "The real tight interface is between the book and the reader - the world of
- the book is plugged right into your brain, never mind the [virtual reality]
- bodysuit"
- -- from The Age of Missing Information, by Bill McKibben.
-